<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--点击事件中调用方法-->
<input type="button" value="按钮" onclick="fn1()">

<script>
    //无参无返回值
    function fn1() {
        alert("fn1");
    }
    //调用方法
    fn1();
    //有参无返回值
    function fn2(name,age) {
        alert(name+":"+age);
    }
    fn2("张飞",18);
    //无参有返回值
    function fn3() {
        return "我是返回值";
    }
    alert(fn3());
    //有参有返回值
    function fn4(x,y) {
        return x*y;
    }
    let result = fn4(8,9);
    alert(result);

    //第二种声明方法的方式
    let fn5 = function (name,age) {
        alert(name+":"+age);
    }
    //调用
    fn5("刘备",30);

    //第三种声明方法的方式
    let fn6 = new Function("name","age","alert(name+':'+age)");
    fn6("关羽","25");





</script>
</body>
</html>